home *** CD-ROM | disk | FTP | other *** search
- package javax.swing;
-
- import java.awt.Component;
- import java.awt.Graphics;
- import java.io.IOException;
- import java.io.ObjectOutputStream;
- import javax.accessibility.Accessible;
- import javax.accessibility.AccessibleContext;
- import javax.accessibility.AccessibleState;
- import javax.swing.event.ChangeEvent;
- import javax.swing.event.ChangeListener;
- import javax.swing.plaf.ProgressBarUI;
-
- public class JProgressBar extends JComponent implements SwingConstants, Accessible {
- private static final String uiClassID = "ProgressBarUI";
- protected int orientation;
- protected boolean paintBorder;
- protected BoundedRangeModel model;
- protected String progressString;
- protected boolean paintString;
- private static final int defaultMinimum = 0;
- private static final int defaultMaximum = 100;
- private static final int defaultOrientation = 0;
- protected transient ChangeEvent changeEvent;
- protected ChangeListener changeListener;
- // $FF: synthetic field
- static Class class$javax$swing$event$ChangeListener;
-
- public JProgressBar() {
- this(0);
- }
-
- public JProgressBar(int var1) {
- this(var1, 0, 100);
- }
-
- public JProgressBar(int var1, int var2) {
- this(0, var1, var2);
- }
-
- public JProgressBar(int var1, int var2, int var3) {
- this.changeEvent = null;
- this.changeListener = null;
- this.setModel(new DefaultBoundedRangeModel(var2, 0, var2, var3));
- this.updateUI();
- this.setOrientation(var1);
- this.setBorderPainted(true);
- this.setStringPainted(false);
- this.setString((String)null);
- }
-
- public JProgressBar(BoundedRangeModel var1) {
- this.changeEvent = null;
- this.changeListener = null;
- this.setModel(var1);
- this.updateUI();
- this.setOrientation(0);
- this.setBorderPainted(true);
- this.setStringPainted(false);
- this.setString((String)null);
- }
-
- public void addChangeListener(ChangeListener var1) {
- super.listenerList.add(class$javax$swing$event$ChangeListener != null ? class$javax$swing$event$ChangeListener : (class$javax$swing$event$ChangeListener = class$("javax.swing.event.ChangeListener")), var1);
- }
-
- // $FF: synthetic method
- static Class class$(String var0) {
- try {
- return Class.forName(var0);
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
- }
-
- protected ChangeListener createChangeListener() {
- return new ModelListener(this);
- }
-
- protected void fireStateChanged() {
- Object[] var1 = super.listenerList.getListenerList();
-
- for(int var2 = var1.length - 2; var2 >= 0; var2 -= 2) {
- if (var1[var2] == (class$javax$swing$event$ChangeListener != null ? class$javax$swing$event$ChangeListener : (class$javax$swing$event$ChangeListener = class$("javax.swing.event.ChangeListener")))) {
- if (this.changeEvent == null) {
- this.changeEvent = new ChangeEvent(this);
- }
-
- ((ChangeListener)var1[var2 + 1]).stateChanged(this.changeEvent);
- }
- }
-
- }
-
- public AccessibleContext getAccessibleContext() {
- if (super.accessibleContext == null) {
- super.accessibleContext = new AccessibleJProgressBar(this);
- }
-
- return super.accessibleContext;
- }
-
- public int getMaximum() {
- return this.getModel().getMaximum();
- }
-
- public int getMinimum() {
- return this.getModel().getMinimum();
- }
-
- public BoundedRangeModel getModel() {
- return this.model;
- }
-
- public int getOrientation() {
- return this.orientation;
- }
-
- public double getPercentComplete() {
- long var1 = (long)(this.model.getMaximum() - this.model.getMinimum());
- double var3 = (double)this.model.getValue();
- double var5 = (var3 - (double)this.model.getMinimum()) / (double)var1;
- return var5;
- }
-
- public String getString() {
- if (this.progressString != null) {
- return this.progressString;
- } else {
- int var1 = (int)Math.round((double)100.0F * this.getPercentComplete());
- return new String(var1 + "%");
- }
- }
-
- public ProgressBarUI getUI() {
- return (ProgressBarUI)super.ui;
- }
-
- public String getUIClassID() {
- return "ProgressBarUI";
- }
-
- public int getValue() {
- return this.getModel().getValue();
- }
-
- public boolean isBorderPainted() {
- return this.paintBorder;
- }
-
- public boolean isStringPainted() {
- return this.paintString;
- }
-
- protected void paintBorder(Graphics var1) {
- if (this.isBorderPainted()) {
- super.paintBorder(var1);
- }
-
- }
-
- protected String paramString() {
- String var1 = this.orientation == 0 ? "HORIZONTAL" : "VERTICAL";
- String var2 = this.paintBorder ? "true" : "false";
- String var3 = this.progressString != null ? this.progressString : "";
- String var4 = this.paintString ? "true" : "false";
- return super.paramString() + ",orientation=" + var1 + ",paintBorder=" + var2 + ",paintString=" + var4 + ",progressString=" + var3;
- }
-
- public void removeChangeListener(ChangeListener var1) {
- super.listenerList.remove(class$javax$swing$event$ChangeListener != null ? class$javax$swing$event$ChangeListener : (class$javax$swing$event$ChangeListener = class$("javax.swing.event.ChangeListener")), var1);
- }
-
- public void setBorderPainted(boolean var1) {
- boolean var2 = this.paintBorder;
- this.paintBorder = var1;
- ((JComponent)this).firePropertyChange("borderPainted", var2, this.paintBorder);
- if (this.paintBorder != var2) {
- ((Component)this).repaint();
- }
-
- }
-
- public void setMaximum(int var1) {
- this.getModel().setMaximum(var1);
- }
-
- public void setMinimum(int var1) {
- this.getModel().setMinimum(var1);
- }
-
- public void setModel(BoundedRangeModel var1) {
- BoundedRangeModel var2 = this.getModel();
- if (var1 != var2) {
- if (var2 != null) {
- var2.removeChangeListener(this.changeListener);
- this.changeListener = null;
- }
-
- this.model = var1;
- if (var1 != null) {
- this.changeListener = this.createChangeListener();
- var1.addChangeListener(this.changeListener);
- }
-
- if (super.accessibleContext != null) {
- super.accessibleContext.firePropertyChange("AccessibleValue", var2 == null ? null : new Integer(var2.getValue()), var1 == null ? null : new Integer(var1.getValue()));
- }
-
- this.model.setExtent(0);
- ((Component)this).repaint();
- }
-
- }
-
- public void setOrientation(int var1) {
- if (this.orientation != var1) {
- switch (var1) {
- case 0:
- case 1:
- int var2 = this.orientation;
- this.orientation = var1;
- ((JComponent)this).firePropertyChange("orientation", var2, var1);
- if (super.accessibleContext != null) {
- super.accessibleContext.firePropertyChange("AccessibleState", var2 == 1 ? AccessibleState.VERTICAL : AccessibleState.HORIZONTAL, this.orientation == 1 ? AccessibleState.VERTICAL : AccessibleState.HORIZONTAL);
- }
-
- ((JComponent)this).revalidate();
- break;
- default:
- throw new IllegalArgumentException(var1 + " is not a legal orientation");
- }
- }
-
- }
-
- public void setString(String var1) {
- String var2 = this.progressString;
- this.progressString = var1;
- ((JComponent)this).firePropertyChange("string", var2, this.progressString);
- if (this.progressString == null || var2 == null || !this.progressString.equals(var2)) {
- ((Component)this).repaint();
- }
-
- }
-
- public void setStringPainted(boolean var1) {
- boolean var2 = this.paintString;
- this.paintString = var1;
- ((JComponent)this).firePropertyChange("stringPainted", var2, this.paintString);
- if (this.paintString != var2) {
- ((JComponent)this).revalidate();
- ((Component)this).repaint();
- }
-
- }
-
- public void setUI(ProgressBarUI var1) {
- super.setUI(var1);
- }
-
- public void setValue(int var1) {
- BoundedRangeModel var2 = this.getModel();
- int var3 = var2.getValue();
- var2.setValue(var1);
- if (super.accessibleContext != null) {
- super.accessibleContext.firePropertyChange("AccessibleValue", new Integer(var3), new Integer(var2.getValue()));
- }
-
- }
-
- public void updateUI() {
- this.setUI((ProgressBarUI)UIManager.getUI(this));
- }
-
- private void writeObject(ObjectOutputStream var1) throws IOException {
- var1.defaultWriteObject();
- if (super.ui != null && this.getUIClassID().equals("ProgressBarUI")) {
- super.ui.installUI(this);
- }
-
- }
- }
-